<?php

use think\migration\Migrator;
use think\migration\db\Column;

class ConfigMini extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('config_mini',['comment' => '小程序配置'])
            ->addColumn('company_id', 'integer', ['limit' => 10, 'after' => 'id', 'default' => 0, 'comment' => '公司ID'])
            ->addColumn('appid','string',['limit' => 50,"default" => "","after"=>"company_id",'comment' => '小程序appid'])
            ->addColumn('app_secret','string',['limit' => 50,"default" => "","after"=>"appid",'comment' => '小程序app_secret'])
            ->addColumn('mch_id','string',['limit' => 50,"default" => "","after"=>"app_secret",'comment' => '小程序mch_id'])
            ->addColumn('mch_key','string',['limit' => 50,"default" => "","after"=>"mch_id",'comment' => '小程序mch_key'])
            ->addColumn('notify_url','string',['limit' => 255,"default" => "","after"=>"mch_key",'comment' => '小程序notify_url'])
            ->addColumn('name','string',['limit' => 50,"default" => "","after"=>"notify_url",'comment' => '小程序名称'])
            ->addColumn('logo','string',['limit' => 500,"default" => "","after"=>"name",'comment' => '小程序Logo'])
            ->addColumn('banner','string',['limit' => 2000,"default" => "","after"=>"logo",'comment' => '小程序banner'])
            ->addColumn('api_key','string',['limit' => 50,"default" => "","after"=>"banner", 'comment' => '小程序支付api_key'])
            ->addColumn('api_cert','string',['limit' => 2000,"default" => "","after"=>"api_key", 'comment' => '小程序支付证书'])
            ->addColumn('api_cert_pem','string',['limit' => 2000,"default" => "","after"=>"api_cert", 'comment' => '小程序支付秘钥'])
            ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'after' => 'api_cert_pem', 'comment' => '1:正常,2:禁用'])
            ->addColumn('create_time', 'integer', ['limit' => 10, 'after' => 'status', 'default' => 0, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit' => 10, 'after' => 'create_time', 'default' => 0, 'comment' => '更新时间'])
            ->addColumn('delete_time', 'integer', ['limit' => 10, 'after' => 'update_time', 'default' => 0, 'comment' => '删除时间'])
            ->create();
    }
}
